package com.gxnzd.communityelderly.controller;

import com.gxnzd.communityelderly.commom.R;
import com.gxnzd.communityelderly.entity.Criticize;
import com.gxnzd.communityelderly.service.CriticizeService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: CriticizeController
 * Package: com.gxnzd.communityelderly.controller
 * Description:
 *
 * @Author 胡海峰
 * @Create 2024/11/22 15:36
 * @Version 1.0
 */
@RestController
@CrossOrigin
@RequestMapping("/criticize")
public class CriticizeController {
    @Resource
    private CriticizeService criticizeService;

    //添加评论
    @PostMapping("/add")
    public R addCriticize(@RequestBody Criticize criticize){
        return criticizeService.addCriticize(criticize);
    }

    //获取评论列表
    @GetMapping("/list")
    public R getCriticizePageList(
            Integer page,
            Integer pageSize,
            String criticizeContent,
            Integer userId
    ){
        return criticizeService.getCriticizeList(page,pageSize,criticizeContent,userId);
    }

    //删除评论
    @DeleteMapping("/delete/{criticizeId}")
    public R deleteCriticize(@PathVariable Long criticizeId){
        return criticizeService.deleteCriticizeInfo(criticizeId);
    }

    //根据帖子id获取评论列表
    @GetMapping("/postCriticizeList")
    public R getPostCriticizeList(Integer postId,Integer userId){
        return criticizeService.getPostCriticizeList(postId,userId);
    }
}
